package voxbox.wrapper;

import processing.core.PMatrix;
import processing.core.PMatrix3D;
import processing.core.PVector;

import com.sun.jna.Structure;

public class PolT extends Structure {

	public float x, y, z;
	public int p2;
	
	public PolT() {
		setAlignType(Structure.ALIGN_NONE);
	}
	
	public static PolT[] CreatePolygon(int n) {
		PolT pt_addr = new PolT(); 
		PolT poly[] = (PolT[])pt_addr.toArray(n);
		return poly;
	}
	
	public void set(PMatrix m, PVector v, int pp2) {
		float[] in = new float[4];
		float[] out = new float[4];
		in[0] = v.x;
		in[1] = v.y;
		in[2] = v.z;
		in[3] = 1;
		
		m.mult(in, out);
		x = out[0];
		y = out[1];
		z = out[2];
		//System.out.println(in[0] + "," + in[1] + "," + in[2] + " -> " + out[0] + "," + out[1] + "," + out[2]);
		p2 = pp2;
	}
	
	public void set(float xx, float yy, float zz, int pp2) {
		x = xx;
		y = yy;
		z = zz;
		p2 = pp2;
	}
}